home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 1 (Walnut Creek)
/
Aminet - June 1993 [Walnut Creek].iso
/
usenet
/
sources
/
volume91
/
aplictns
/
mandel10
/
part01
/
mandel.doc
< prev
next >
Wrap
Text File
|
1991-02-18
|
14KB
|
370 lines
-----------------------------------------------------------------------------
Version history
v0.50 First numbered version. Most bugs I've found are fixed.
v0.60 Workbench interface added.
v1.00 First public release.
-----------------------------------------------------------------------------
BUGS
- Not very smart handling of AUTOCRAWL
- If invoked with too little memory, 56 bytes will mysteriously
disappear
- Window title bar may get trashed if moved too high
-----------------------------------------------------------------------------
Copying licence:
This program is copyright 1990 by Hannu Helminen. However, you may
freely distribute it provided that this package is left intact and no
charge is taken. You are also licenced to use parts of the code in your
programs provided that
1) New versions are clearly marked as such
2) You give credit where credit is due (me)
I will not guarantee anything about this program. It seems quite
reliable to me, though.
-----------------------------------------------------------------------------
Package includes:
mandel Main proggie
mandel.doc This file
iff.library Used when saving pictures. Place in libs: directory.
source/gui.asm Graphical user interface
source/brot.asm This takes care of the actual drawing
source/pipe.asm A package of fifo routines, as needed by brot
source/macros.i General macros
source/mbrot.i brot-specific include file, including my own structure
source/iff.i Needed to use iff.library
-----------------------------------------------------------------------------
OVERVIEW
There are quite a few Mandelbrot programs for Amiga, perhaps to the
extent that I should have named my program "yamb" instead of "mandel".
(Yet Another MandelBrot)
I hope though that there are enough reasons to satisfy the existence of
this program. Namely, it was designed with three goals in mind: first,
speed. Secondly, speed. And last but not least, speed.
Of course, most Mandelbrot programs draw nice-looking pictures, if only
you can wait for ten minutes or even more for them to be complete.
Increase the number of iterations and you will have to wait for hours,
unless you are one of those lucky guys with a 60-MHz 68040-equipped
A3000's... The main reason for that slowness is the floating point math
most programs use.
The first version of this program was quite ugly: coded partly in
Basic, partly in 68000 machine language, it was a mess of a code. Its
optimized core used 32-bit fixed point math but was still relatively
slow. After writing it, I forgot it for years.
Then someone in alt.fractals told about a new algorithm called contour
crawling that produces fast images of Mandelbrot set. I adopted the
idea and rewrote the program to use it, this time completely in machine
language. It turned out to be fast (within minutes); that is because it
does not need to iterate all pixels. And the drawing was visually
attractive, so it suits well for interactive use.
After imploying a 16-bit iteration for lower resolutions, I found I had
written the fastest Mandelbrot program I had ever seen. (Ok, forget
that little transputer...) I cannot pretend to have seen even all Amiga
ones, though, so there may already be a faster one. If so, please tell
me that all this code was in vain.
USAGE
Start from CLI by typing `mandel', or click the icon in Workbench. The
program will then immediately begin to draw the Mandelbrot set. Various
options exists, however, to modify how, where and when the image will
be drawn. Use CTRL-C to abort a draw in progress, and another CTRL-C to
abort the program.
From CLI: Enter the options after the command, e.g.
mandel -i1000 -j -sram:Picture
Type `mandel ?' to see a brief summary of the options.
From Workbench: Select mandel icon, select `info' from the `Workbench'
menu and enter options in the TOOL TYPES array, e.g.
I=100
FLAGS=j
SAVE=ram:Picture
The options are listed below. # is a shorthand for a number.
CLI WorkBench
-x# X=# These determine the point (z = x + yi) in the complex
-y# Y=# plane you will see right in the center of your monitor.
They are in the range -4 to 4.
-m# M=# This is a logarithmic quantity that represents the
magnification of the image. 2^(-m) determines the
distance between two lo-res pixels in complex plane.
Default is 6, maximum is 29.
-i# I=# Iterations. Self-explanatory? No? The greater the
number, the more accurate pictures mandel will draw.
For further information, refer to APPENDIX A.
The maximum number of iterations is 65535.
-jx# JX=# These determine a constant (c = jx + jy i) that is used
-jy# JY=# when iterating a Julia set. Each c will produce a
different set. See APPENDIX A. These, too, have a range
from -4 to 4.
-sname SAVE=name This determines a filename for saved pictures.
If mandel is operated interactively (g flag is set),
the user can save pictures by pressing CTRL S. The
standard filename is `mandel.picture', but can be
overridden by this option. If many pictures are saved,
a number is added at the end to distinguish the files
from each other.
If mandel is in non-interactive use (x flag is set),
this options specifies that the image must be saved
upon exit, and determines the name for it. Note: if
this option does not exists, no image will be saved.
-l FLAGS=l Normally mandel determines itself whether it should use
-h FLAGS=h 16 or 32 bits of precision, as denoded by (a). There
-a FLAGS=a are certain, limited circumstances when you need to set
the precision explicitely to 16 (l) or 32 (h) bits. In
particular, Julia sets that have a complex structure
near origo may produce inaccurate images unless 32 bits
are used.
-c FLAGS=c You can enable (c) or disable (w) the crawling if you
-w FLAGS=w wish, default is (p), which means to crawl whenever
-p FLAGS=p possible. Currently non-connected Julia sets are not
crawled because they *could* produce inaccurate
results. Future versions might add more sanity checks
to this.
-x FLAGS=x When the (x) flag is used, the programs exits
-g FLAGS=g immediately after the first image is drawn. Default is
(g) which means to prompt the user with a
requester-like window (See below). The x flag is
intented for non-interactive use, for example
continuous zooms that are achieved via scripts.
-m FLAGS=m Whether you want to draw Julia (j) or Mandelbrot (m)
-j FLAGS=j sets. See APPENDIX A.
NOTE: In Workbench, if multiple FLAGS are used, they *must* be
combined in a single FLAGS entry, e.g.
FLAGS=apgx
In CLI, flags *must not* be combined, so do not try `-apgx'
instead of `-a -p -g -x'.
GRAPHICAL USER INTERFACE
When mandel is invoked with the -g option, after the first image is
drawn, a requester-like window will pop in. A grid will also be
displayed, indicating the centerpoint and borders of the next image.
Screen title bar will show coordinates of the mouse position.
You can then set the centerpoint by clicking in the image or entering a
value in the string gadgets labeled `X' and `Y'. Magnification and
iterations can be set in the gadgets `M' and `I', respectively.
A new quantity can be set using the `Z' gadget: zooming. As its name
implies, this determines which portion of the current image will be
shown in the next one. This is a signed number that will be added to
magnification, thus set z=0 for 100% zooming, z=1 for 50%, z=-1 for
200% etc. This can also be set by pressing the right mouse button and
moving it over the image.
The program draws images in one of three modes: ZOOM, DRAW and RESET.
ZOOM means zooming to the size shown by the grid. DRAW will take the
numbers from the requester and draw according to them (used for example
to redraw the same picture, or to quickly enter a very deep
magnification level)
As setting zoom in DRAW mode makes as little sense as setting
magnification in ZOOM mode, these modifications will immediately change
the draw mode, too. The third mode, RESET, will return the
magnification and centerpoint to normal. The mode can be changed by
respective gadgets.
Clicking MAND or JULIA will change the set type to Mandelbrot or Julia.
The magical constant c for Julia sets (See APPENDIX A) can be set as
follows: Make sure you are in MAND mode. Then select the point c by
either clicking on the image or entering it in the X/Y-gadgets. Then
click JULIA gadget and select whatever centerpoint you wish your image
to have.
Alas, window close gadget only removes the requester window, screen
title and grid in order to let you view the image. Normal operation is
resumed by pressing either mouse button.
Quit the program by double-clicking the QUIT gadget or draw a new set
by double-clicking either in the image or one of the gadgets ZOOM,
DRAW, RESET.
AUTHOR
Hannu "The DM" Helminen
Perkkio
85900 REISJARVI
FINLAND
dm@stekt.oulu.fi (for the next few years, I hope)
THANKS
Thanks to
T. Saarinen for extensive beta-testing
'LS' Hautamaki for not-so-extensive testing
J.M. Jarre who was in great help during long nights of programming
B. Mandelbrot who invented the set that carries his name
APPENDIX A: A mathematical definition of Mandelbrot and Julia sets.
A point z = x + y i is said to be in the Mandelbrot set if
0
2
z = z + c does not go to +-oo (infinity) when n -> oo
n+1 n
____
where c = z . ( i = ,/ -1 so z, c are complex numbers )
0
A point z = x + y i is said to be in the Julia set c if
0
2
z = z + c does not -> oo when n -> oo
n+1 n
NOTE: There are an infinite number of Julia sets, each corresponding to
one value of c. c is also related to a point in the Mandelbrot set.
(originally the Mandelbrot set was the set of c's that will produce a
*connected* Julia set.) Note also that the Julia set looks similar to
the surroundings of that point in the Mandelbrot set from which the
Julia set was derived.
Becausese these calculations would take a considerable amount of time
with any contemporary computer, they are approximated by a finite
number of iterations (typically 100 or more). An usual test for a point
z going to infinity is to test whether or not | z | < 2. And since few
computers can calculate with complex numbers, we can rewrite the
equation (z -> z**2 + c) in a C-ish style program using only real
variables z = x + y i:
i = max_iterations;
while (i > 0 && x**2 + y**2 < 4) {
tmpx = x**2 - y**2 + x0;
tmpy = 2 x y + y0;
x = tmpx;
y = tmpy;
i--;
}
if (i=0) inside (); else outside();
If you are a first-time user of any Mandelbrot program, I might suggest
that you study the edge of the black area, because that is where the
most interesting parts of the set are. (The coloured areas do not
actually belong to the set, and the interior is, of course, all
black...)
APPENDIX B: The contour crawling method
This method works by finding an edge of an area of uniform color, then
crawling its way through the edge until starting point is reached. The
interior is then assumed to be of same color. This is of course true
for the ideal set, but because the image is sampled to a finite set of
pixels, errors *may* occur. (Haven't seen one so far, though.)
Non-connected Julia sets must not be crawled in the strict mathematical
sense. However, most of the time mandel produces correct pictures even
then. So it is quite safe to use the -c option of mandel.
APPENDIX C: Compilation
Assuming you have a68k v2.61 or higher and blink, the following
steps are needed to compile a working executable of mandel:
a68k gui.asm -q500 -iinclude:
a68k brot.asm -q200 -iinclude:
a68k pipe.asm -q100
blink gui.o brot.o pipe.o to mandel lib amiga.lib
where include: is assigned to standard assembly include directory.
NOTE: if you have a68k v2.42, gadget arrow images will not be marked as
going to CHIP ram. This will give you strange-looking images unless:
0) You have only CHIP ram (poor chap)
1) You use FastMemFirst, FixHunk, ATOM etc. kludges
2) Modify the code: allocate some CHIP-mem and CopyMem() the images
there. This is a kludge, however.
3) Get v2.62 somewhere (e.g. disk 314 from Fred Fish's
wonderful collection.)
APPENDIX D: How to use brot with your own programs?
Just pass the address of a valid mb-structure in a0 (see mbrot.i),
`jsr MandelBrot' and `XREF MandelBrot' somewhere in your code and
(b)link your proggie with brot.o and pipe.o. The RastPort you use
*must* have valid TmpRas and AreaInfo structures attached to it.
AreaInfo should carry as many vectors as possible (no more than 6553,
however, since that seems to be a maximum)